<template>
	<view class="content">
		<view class="input-block">
			<view class="input-left">
				<input placeholder="请输入关键字" v-model="keyWord" @confirm="search" placeholder-style="color: #AAAAAA" />
			</view>
			<view class="search" @click="getList(true)">搜索</view>
		</view>
		<template v-if="list.length>0">
			<view @click="navigate('/page_other/company/company?id='+item.id+'&type=1')" class="enterprise-item"
				v-for="(item,index) in list" :key="item.id">
				<image :src="item.logoUrl ? item.logoUrl : cloudStorage+'/job_hunting/index/enterprise-icon.png'"
					class="cover-photo"></image>
				<view class="list-info">
					<view class="title">{{item.brandName}}</view>
					<view class="address">
						<view class="add" v-if="item.enterpriseTypeText">{{item.enterpriseTypeText}}
						</view>
						<view class="add" v-else style="margin-left: 0px;">暂无企业类型 </view>
						<view class="add"> · {{item.scaleName}}</view>
					</view>
					<view class="authentication">
						<view class="authentication-item">
							<view class="iconfont icon-yirenzheng"></view>
							<view class="text">营业执照已认证</view>
						</view>
						<view class="authentication-item">
							<view class="iconfont icon-yirenzheng"></view>
							<view class="text">手机号已认证</view>
						</view>
					</view>
					<!-- <view class="positionCount"><text style="color: #0256FF;">{{item.fairCount}}个</text>在招职位
					</view> -->
				</view>
			</view>
		</template>
		<view v-if="more==false&&list.length==0" class="empty">暂无数据</view>
		<view v-else-if="more==false&&list.length>0" class="empty">没有更多了</view>
	</view>
</template>

<script>
	import {
		isMore
	} from '@/util/util.js'
	import {
		getEnjoyEnterprise
	} from '@/api/job_hunting.js';
	export default {
		data() {
			return {
				list: [],
				conf: {
					page: 1,
					limit: 10
				},
				more: true,
				keyWord: ''
			}
		},
		methods: {
			navigate(url) {
				uni.navigateTo({
					url
				})
			},
			refresh() {
				this.conf.page = 1
				this.more = true
				this.getList(true);
			},
			getList(refresh = false) {
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				getEnjoyEnterprise({
					page: this.conf.page,
					limit: this.conf.limit,
					keyword: this.keyWord
				}).then((res) => {
					let list = res.list || [];
					if (refresh) {
						this.list = list;
					} else {
						this.list = [...this.list, ...list]
					}
					this.more = isMore(this.conf.page, this.conf.limit, res.count)
				})
			}
		},
		onReachBottom() {
			if (this.more) {
				this.conf.page++;
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				this.getList();
			}
		},
		onLoad(e) {
			this.getList(true)
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		padding: 30rpx;

		.input-block {
			display: flex;
			border-radius: 50px;
			align-items: center;
			background-color: #FFFFFF;
			justify-content: space-between;
			width: 100%;
			height: 70rpx;
			margin: auto;
			padding: 0 10rpx 0 20rpx;
			margin-bottom: 30rpx;

			.input-left {
				width: calc(100% - 140rpx);
				display: flex;

				input {
					border-radius: 50px;
					width: 100%;
					font-size: 28rpx;
					color: #767676;
				}
			}

			.search {
				display: flex;
				justify-content: center;
				align-items: center;
				width: 120rpx;
				border-radius: 50rpx;
				height: 55rpx;
				padding-bottom: 5rpx;
				color: #FFFFFF;
				background: linear-gradient(90deg, #1C89FD 0%, #22DDE8 100%);
				font-size: 28rpx;
			}
		}

		.enterprise-item {
			width: 100%;
			background: #fff;
			border-radius: 10rpx;
			box-shadow: 0 0 10px 0 #efefef;
			padding: 20rpx;
			display: flex;
			flex-direction: row;
			justify-content: center;
			margin: 20rpx auto;

			.cover-photo {
				width: 150rpx;
				height: 150rpx;
				margin-right: 20rpx;
				border-radius: 20rpx;

			}

			.list-info {
				width: 70%;
				display: flex;
				flex-direction: column;

				view {
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
				}

				.title {
					color: #000;
					font-weight: bold;
					font-size: 34rpx;
				}

				.address {
					display: flex;
					flex-direction: row;

					.add {
						color: #767676;
						font-size: 26rpx;
						margin-top: 20rpx;
					}
				}

				.authentication {
					display: flex;
					align-items: center;
					justify-content: space-between;
					margin-top: 20rpx;

					.authentication-item {
						display: flex;
						align-items: center;

						.iconfont {
							color: #0256FF;
							font-size: 30rpx;
							margin-right: 6rpx;
						}

						.text {
							color: #767676;
							font-size: 26rpx;
						}
					}
				}

				.positionCount {
					font-size: 28rpx;
					margin-top: 20rpx;
					color: #767676;
				}
			}
		}
	}
</style>